package com.leo.ui;

import com.almasb.fxgl.dsl.FXGL;
import com.almasb.fxgl.entity.Entity;
import com.almasb.fxgl.scene.SubScene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;

/**
 * @Author: wangss
 * @CreateTime: 2023-06-18  05:32
 * @Description: TODO
 */
public class CustomSubScene extends SubScene {
    public CustomSubScene() {
        Button ok = new Button("ok");
        ok.setOnAction(event -> FXGL.getSceneService().popSubScene());

        StackPane centerPane = new StackPane(ok);
        centerPane.setMaxSize(320, 180);
        centerPane.setStyle("-fx-background-color: white");

        StackPane bgPane = new StackPane(centerPane);
        bgPane.setPrefSize(FXGL.getAppWidth(), FXGL.getAppHeight());
        bgPane.setStyle("-fx-background-color: #0003; -fx-border-color: skyblue;");

        getContentRoot().getChildren().add(bgPane);
    }

    @Override
    public void onCreate() {
        Entity entity = FXGL.getGameWorld().getEntities().get(0);
        System.out.println(entity.getX() + "------------" + entity.getY());
    }
}
